package com.hhit.bigscreenbackmanage.controller.jsgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.service.jsgl.TJsglSzjjService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/jsgl/szjj")
public class SzjjController {

    private Logger log = LoggerFactory.getLogger(SzjjController.class);

    @Autowired
    TJsglSzjjService tJsglSzjjService;

    /**
     * 查询 数字基建进度明细
     *
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSzjjList")
    public Response getSzjjList(@RequestBody JSONObject jsonObject) {
        try {
            Map<String, Object> result = tJsglSzjjService.querySzjjList(jsonObject);
            return Response.createResponseBySuccess("查询数字基建进度明细成功", result);
        } catch (Exception e) {
            log.error("查询数字基建进度明细失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询数字基建进度明细失败");
        }
    }

    /**
     * 查询 数字基建统计
     *
     * @param jsonObject
     * @return
     */
    @RequestMapping("/getSzjjCount")
    public Response getSzjjCount(@RequestBody JSONObject jsonObject) {
        try {
            Map<String, Integer> result = tJsglSzjjService.querySzjjCount(jsonObject);
            return Response.createResponseBySuccess("查询数字基建统计成功", result);
        } catch (Exception e) {
            log.error("查询数字基建统计失败: " + e.getMessage());
            e.printStackTrace();
            return Response.createResponseByError("查询数字基建统计失败");
        }
    }

    /**
     * 删除 数字基建进度明细
     * @param jsonObject
     * @return
     */
    @RequestMapping("/deleteSzjjRecord")
    public Response deleteSzjjRecord(@RequestBody JSONObject jsonObject){
        try{
            tJsglSzjjService.deleteSzjjRecord(jsonObject);
            return Response.createResponseBySuccess("删除数字基建进度明细成功");
        }catch (Exception e){
            e.printStackTrace();
            return Response.createResponseByError("删除数字基建进度明细失败: "+e.getMessage());
        }
    }
}
